package TestStruct

// -------------1对多的关系，一个领导可以领导多个部门-----------
// 领导表
type Leader struct {
	LID   int `gorm:"primary_key;AUTO_INCREMENT"`
	LName string
	LAge  int
	//ForeignKey:DLID数据存在外表中
	//AssociationForeignKey:LID关联的是本表的字段
	Department []Department `gorm:"ForeignKey:DLID;AssociationForeignKey:LID"`
}

// 部门表
type Department struct {
	DId   int `gorm:"primary_key;AUTO_INCREMENT"`
	DName string
	Desc  string
	//设置外键：
	DLID int
}
